Skip to content

Use the RN packager's host by default#1568

Merged
shilman merged 4 commits intomasterfrom
1222-parse-rn-packager-host
Aug 1, 2017
Merged

Use the RN packager's host by default#1568
shilman merged 4 commits intomasterfrom
1222-parse-rn-packager-host

Conversation

@shilman
Copy link
Copy Markdown
Member

@shilman shilman commented Aug 1, 2017

Issue: #1222

What I did

Use the RN packager's host by default as described in #1222

  • added CRNA example for testing
  • updated the CLI templates

How to test

First:

yarn && yarn bootstrap

Then test RN:

yarn bootstrap:react-native-vanilla
cd examples/react-native-vanilla
yarn storybook
./node_modules/.bin/react-native run-ios

Then test CNRA:

yarn bootstrap:crna-kitchen-sink
cd examples/crna-kitchen-sink
yarn storybook
yarn ios

@shilman shilman changed the title 1222 parse rn packager host Use the RN packager's host by default Aug 1, 2017
@@ -0,0 +1,25 @@
export default from './storybook';

// import React from 'react';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this left here intentionally?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll add to the comment tho. 😄

const StorybookUI = getStorybookUI({
port: 7007,
host: 'localhost',
// host: 'localhost',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be deleted.

};

showApp(event) {
event.preventDefault();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgive my ignorance, but why is preventDefault needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copypasta? i'm not sure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also unsureFWIW

Copy link
Copy Markdown
Member Author

@shilman shilman Aug 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all over the code (part of the CLI boilerplate), so I propose we address it separately 😕

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not typically need to .preventDefault() in React Native. That said I don't see the showApp function used anywhere in this component... so couldn't this method just be removed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although - this might be something CRNA related so if so, please ignore my thoughts on removing it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK OK looks like it isn't used so I'll remove across the board, test, and submit. Thanks 🙇

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On third thought, I think this is a separate issue. This used to be used to show off addon-links but was removed at some point. Opened: #1569

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 1, 2017

Codecov Report

Merging #1568 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1568      +/-   ##
==========================================
- Coverage   20.43%   20.43%   -0.01%     
==========================================
  Files         241      241              
  Lines        5250     5252       +2     
  Branches      656      645      -11     
==========================================
  Hits         1073     1073              
- Misses       3661     3682      +21     
+ Partials      516      497      -19
Impacted Files Coverage Δ
app/react-native/src/preview/index.js 0% <0%> (ø) ⬆️
lib/ui/src/modules/ui/configs/handle_routing.js 28.94% <0%> (ø) ⬆️
app/react-native/src/bin/storybook-start.js 0% <0%> (ø) ⬆️
addons/notes/src/react.js 0% <0%> (ø) ⬆️
addons/knobs/src/KnobManager.js 35.41% <0%> (ø) ⬆️
lib/ui/src/modules/ui/routes.js 0% <0%> (ø) ⬆️
app/react/src/client/preview/element_check.js 41.17% <0%> (ø) ⬆️
app/react/src/client/preview/error_display.js 0% <0%> (ø) ⬆️
addons/info/src/components/markdown/htags.js 30% <0%> (ø) ⬆️
lib/ui/src/modules/ui/libs/filters.js 53.33% <0%> (ø) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7cdc25a...67a7093. Read the comment docs.

Copy link
Copy Markdown
Member

@orta orta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the same code in our non-CRNA app, and everything was good:

import { NativeModules } from "react-native"
console.log(NativeModules.SourceCode.scriptURL)

And got http://localhost:8081/Example/Emission/index.ios.bundle?platform=ios&dev=true&hot=true

So this is fine for non-CRNA too 👍

@shilman shilman merged commit d7bc10d into master Aug 1, 2017
@shilman shilman deleted the 1222-parse-rn-packager-host branch August 1, 2017 19:41
if (params.resetStorybook || !channel) {
const host = params.host || 'localhost';

const host = params.host || parse(NativeModules.SourceCode.scriptURL).hostname;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant - didn’t know this was an accessible thing

const host = params.host || 'localhost';

const host = params.host || parse(NativeModules.SourceCode.scriptURL).hostname;
const port = params.port !== false ? `:${params.port || 7007}` : '';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the port for the ReactNative packager? Or where storybooks web previewed will be binding to?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the storybook port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants